import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BookingOrderMasterApi } from '#/api/spa/booking/ordermaster';

import { getDictOptions, getRangePickerDefaultProps } from '#/utils';
import { DICT_SPA_TYPE } from '#/utils/dictSpa';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'orderCode',
      label: '预约订单编码',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预约订单编码',
      },
    },
    {
      fieldName: 'orderType',
      label: '订单类型',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择订单类型',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'customerPhone',
      label: '客户电话',
      component: 'Input',
      componentProps: {
        placeholder: '请输入客户电话',
      },
    },
    {
      fieldName: 'customerGender',
      label: '性别',
      component: 'Input',
      componentProps: {
        placeholder: '请输入性别',
      },
    },
    {
      fieldName: 'customerAge',
      label: '年龄',
      component: 'Input',
      componentProps: {
        placeholder: '请输入年龄',
      },
    },
    {
      fieldName: 'groupId',
      label: '团体ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体ID',
      },
    },
    {
      fieldName: 'groupSequence',
      label: '团体中的序号',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体中的序号',
      },
    },
    {
      fieldName: 'groupLeaderId',
      label: '团体负责人ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入团体负责人ID',
      },
    },
    {
      fieldName: 'bookingDate',
      label: '预约日期',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'expectedArrivalTime',
      label: '预计到店时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'lateArrivalTolerance',
      label: '迟到容忍时间(分钟)',
      component: 'Input',
      componentProps: {
        placeholder: '请输入迟到容忍时间(分钟)',
      },
    },
    {
      fieldName: 'bookingStatus',
      label: '预约状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'payStatus',
      label: '支付状态',
      rules: 'required',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'priorityLevel',
      label: '优先级',
      component: 'Input',
      componentProps: {
        placeholder: '请输入优先级',
      },
    },
    {
      fieldName: 'convertedConsumptionOrderId',
      label: '转换后的消费订单ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入转换后的消费订单ID',
      },
    },
    {
      fieldName: 'conversionTime',
      label: '转换时间',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    {
      fieldName: 'conversionUserId',
      label: '转换操作人ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入转换操作人ID',
      },
    },
    {
      fieldName: 'orderSource',
      label: '订单来源',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入订单来源',
      },
    },
    {
      fieldName: 'sourceChannel',
      label: '来源渠道',
      component: 'Input',
      componentProps: {
        placeholder: '请输入来源渠道',
      },
    },
    {
      fieldName: 'referralCode',
      label: '推荐码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入推荐码',
      },
    },
    {
      fieldName: 'specialRequirements',
      label: '特殊需求',
      component: 'Input',
      componentProps: {
        placeholder: '请输入特殊需求',
      },
    },
    {
      fieldName: 'healthNotes',
      label: '健康备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入健康备注',
      },
    },
    {
      fieldName: 'orderNotes',
      label: '订单备注',
      component: 'Input',
      componentProps: {
        placeholder: '请输入订单备注',
      },
    },
    {
      fieldName: 'estimatedTotalAmount',
      label: '预估总金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估总金额',
      },
    },
    {
      fieldName: 'estimatedDiscountAmount',
      label: '预估折扣金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估折扣金额',
      },
    },
    {
      fieldName: 'estimatedFinalAmount',
      label: '预估最终金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入预估最终金额',
      },
    },
    {
      fieldName: 'depositAmount',
      label: '押金金额',
      component: 'Input',
      componentProps: {
        placeholder: '请输入押金金额',
      },
    },
    {
      fieldName: 'depositStatus',
      label: '押金状态',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'reminderSent',
      label: '是否已发送提醒',
      component: 'RadioGroup',
      componentProps: {
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        buttonStyle: 'solid',
        optionType: 'button',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      rules: 'required',
      component: 'Input',
      componentProps: {
        placeholder: '请输入组织ID',
      },
    },
  ];
}

/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'orderCode',
      label: '预约订单编码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入预约订单编码',
      },
    },
    {
      fieldName: 'orderType',
      label: '订单类型',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择订单类型',
      },
    },
    {
      fieldName: 'customerId',
      label: '客户ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户ID',
      },
    },
    {
      fieldName: 'customerName',
      label: '客户姓名',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户姓名',
      },
    },
    {
      fieldName: 'customerPhone',
      label: '客户电话',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入客户电话',
      },
    },
    {
      fieldName: 'customerGender',
      label: '性别',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入性别',
      },
    },
    {
      fieldName: 'customerAge',
      label: '年龄',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入年龄',
      },
    },
    {
      fieldName: 'groupId',
      label: '团体ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体ID',
      },
    },
    {
      fieldName: 'groupSequence',
      label: '团体中的序号',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体中的序号',
      },
    },
    {
      fieldName: 'groupLeaderId',
      label: '团体负责人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入团体负责人ID',
      },
    },
    {
      fieldName: 'bookingDate',
      label: '预约日期',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'expectedArrivalTime',
      label: '预计到店时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },

    {
      fieldName: 'bookingStatus',
      label: '预约状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择预约状态',
      },
    },
    {
      fieldName: 'payStatus',
      label: '支付状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择支付状态',
      },
    },
    {
      fieldName: 'priorityLevel',
      label: '优先级',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入优先级',
      },
    },
    {
      fieldName: 'convertedConsumptionOrderId',
      label: '转换后的消费订单ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入转换后的消费订单ID',
      },
    },
    {
      fieldName: 'conversionTime',
      label: '转换时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    {
      fieldName: 'conversionUserId',
      label: '转换操作人ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入转换操作人ID',
      },
    },
    {
      fieldName: 'orderSource',
      label: '订单来源',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入订单来源',
      },
    },
    {
      fieldName: 'sourceChannel',
      label: '来源渠道',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入来源渠道',
      },
    },
    {
      fieldName: 'referralCode',
      label: '推荐码',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入推荐码',
      },
    },

    {
      fieldName: 'depositStatus',
      label: '押金状态',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'string'),
        placeholder: '请选择押金状态',
      },
    },
    {
      fieldName: 'reminderSent',
      label: '是否已发送提醒',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_SPA_TYPE.SPA_Settlement_Status, 'boolean'),
        placeholder: '请选择是否已发送提醒',
      },
    },
    {
      fieldName: 'storeId',
      label: '门店ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入门店ID',
      },
    },
    {
      fieldName: 'orgId',
      label: '组织ID',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入组织ID',
      },
    },
    {
      fieldName: 'createTime',
      label: '创建时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BookingOrderMasterApi.BookingOrderMaster>['columns'] {
  return [
    {
      field: 'id',
      title: '预约订单ID',
      minWidth: 120,
    },
    {
      field: 'orderCode',
      title: '预约订单编码',
      minWidth: 120,
    },
    {
      field: 'orderType',
      title: '订单类型',
      minWidth: 120,
    },
    {
      field: 'customerId',
      title: '客户ID',
      minWidth: 120,
    },
    {
      field: 'customerName',
      title: '客户姓名',
      minWidth: 120,
    },
    {
      field: 'customerPhone',
      title: '客户电话',
      minWidth: 120,
    },
    {
      field: 'customerGender',
      title: '性别',
      minWidth: 120,
    },
    {
      field: 'customerAge',
      title: '年龄',
      minWidth: 120,
    },
    {
      field: 'groupId',
      title: '团体ID',
      minWidth: 120,
    },
    {
      field: 'groupSequence',
      title: '团体中的序号',
      minWidth: 120,
    },
    {
      field: 'groupLeaderId',
      title: '团体负责人ID',
      minWidth: 120,
    },
    {
      field: 'bookingDate',
      title: '预约日期',
      minWidth: 120,
    },
    {
      field: 'expectedArrivalTime',
      title: '预计到店时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'lateArrivalTolerance',
      title: '迟到容忍时间(分钟)',
      minWidth: 120,
    },
    {
      field: 'bookingStatus',
      title: '预约状态',
      minWidth: 120,
    },
    {
      field: 'payStatus',
      title: '支付状态',
      minWidth: 120,
    },
    {
      field: 'priorityLevel',
      title: '优先级',
      minWidth: 120,
    },
    {
      field: 'convertedConsumptionOrderId',
      title: '转换后的消费订单ID',
      minWidth: 120,
    },
    {
      field: 'conversionTime',
      title: '转换时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'conversionUserId',
      title: '转换操作人ID',
      minWidth: 120,
    },
    {
      field: 'orderSource',
      title: '订单来源',
      minWidth: 120,
    },
    {
      field: 'sourceChannel',
      title: '来源渠道',
      minWidth: 120,
    },
    {
      field: 'referralCode',
      title: '推荐码',
      minWidth: 120,
    },
    {
      field: 'specialRequirements',
      title: '特殊需求',
      minWidth: 120,
    },
    {
      field: 'healthNotes',
      title: '健康备注',
      minWidth: 120,
    },
    {
      field: 'orderNotes',
      title: '订单备注',
      minWidth: 120,
    },
    {
      field: 'estimatedTotalAmount',
      title: '预估总金额',
      minWidth: 120,
    },
    {
      field: 'estimatedDiscountAmount',
      title: '预估折扣金额',
      minWidth: 120,
    },
    {
      field: 'estimatedFinalAmount',
      title: '预估最终金额',
      minWidth: 120,
    },
    {
      field: 'depositAmount',
      title: '押金金额',
      minWidth: 120,
    },
    {
      field: 'depositStatus',
      title: '押金状态',
      minWidth: 120,
    },
    {
      field: 'reminderSent',
      title: '是否已发送提醒',
      minWidth: 120,
    },
    {
      field: 'storeId',
      title: '门店ID',
      minWidth: 120,
    },
    {
      field: 'orgId',
      title: '组织ID',
      minWidth: 120,
    },
    {
      field: 'createTime',
      title: '创建时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
